﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;

namespace iOSClub.CheckInApi.DataModels;

/// <summary>
/// 打卡具体信息
/// </summary>
public class CheckModel : DataModel
{
    [Key]
    [Column(TypeName = "varchar(64)")]
    public string Key { get; set; } = "";

    [Column(TypeName = "varchar(64)")] public string Name { get; set; } = "";

    [Column(TypeName = "DATE")] public DateTime CheckTime { get; set; } = DateTime.Now;

    [Column(TypeName = "varchar(512)")] public string Content { get; set; } = "";

    public UserModel User { get; set; } = new();

    [Column(TypeName = "varchar(10)")] public string UserId { get; set; } = "";

    public SeriesModel? Series { get; set; }
    [Column(TypeName = "varchar(64)")] public string? SeriesId { get; set; }

    public void Update(CheckModel model)
    {
        if (!string.IsNullOrEmpty(model.Name)) Name = model.Name;
        if (!string.IsNullOrEmpty(model.Content)) Content = model.Content;
    }
}